package com.cloudbroker.bcs.csvc.credits.bizservice.impl;

import com.cloudbroker.bcs.csvc.credits.api.service.TkOpenBizService;
import com.cloudbroker.bcs.csvc.credits.api.vo.back.*;
import com.cloudbroker.bcs.csvc.credits.api.vo.back.CreditsBackVO;
import com.cloudbroker.bcs.csvc.credits.api.vo.back.CreditsVO;
import com.cloudbroker.bcs.csvc.credits.api.vo.back.ResultVO;
import com.cloudbroker.bcs.csvc.credits.api.vo.request.CreditsOperForm;
import com.cloudbroker.bcs.csvc.credits.api.vo.request.QueryCreditsForm;
import com.cloudbroker.bcs.csvc.credits.api.vo.request.QueryCreditslogForm;
import com.cloudbroker.bcs.csvc.credits.api.vo.request.UserCreditsForm;
import com.cloudbroker.bcs.csvc.credits.service.TKOpenService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by lili19289 on 2016/11/7.
 */
@Service
public class TkOpenBizServiceImpl implements TkOpenBizService {


    @Resource
    private TKOpenService tkOpenService;

    @Transactional
    public CreditsVO functionAddCredits(CreditsOperForm form) {
        Map<String,String> paramMap = new HashMap<>();
        paramMap.put("integral",form.getOpera_credits()+"");
        paramMap.put("source",form.getSource());
        paramMap.put("mobile_phone",form.getMobile());
        IntegralBackVO integralBackVO = tkOpenService.func_add_integral(paramMap);
        return new CreditsVO(integralBackVO);
    }

    public CreditsVO functionConsumeCredits(CreditsOperForm form){
        Map<String,String> paramMap = new HashMap<>();
        paramMap.put("integral",form.getOpera_credits()+"");
        paramMap.put("source",form.getSource());
        paramMap.put("mobile_phone",form.getMobile());
        IntegralBackVO integralBackVO = tkOpenService.func_consum_integral(paramMap);
        return new CreditsVO(integralBackVO);
    }

    public CreditsVO functionGetCreditsByUser(UserCreditsForm form){
        Map<String,String> paramMap = new HashMap<>();
        paramMap.put("mobile_phone",form.getMobile());
        IntegralQueryBackVO integralQueryBackVO = tkOpenService.func_query_integral(paramMap);
         return new CreditsVO(integralQueryBackVO);
    }

    public ResultVO functionQueryCredits(QueryCreditsForm form){
       return null;
    }

    public ResultVO functionQueryCreditsLog(QueryCreditslogForm form){
       return null;
    }




}
